//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _VIEWATTRIBUTEGROUP_H
#define _VIEWATTRIBUTEGROUP_H
#include <QHash>
#include <QObject>
#include <QPointer>
#include <QVariant>
#include "document.h"
class AttrEvent;
class View;
class ViewAttribute;
//
enum ViewAttributeName {
   root_object
};
//
class ViewAttributeGroup : public QObject {
   Q_OBJECT
   Q_DISABLE_COPY(ViewAttributeGroup)
public:
   ViewAttributeGroup(Document *doc, QObject *parent = 0);
   ~ViewAttributeGroup();
   void add_attribute(ViewAttribute *attr);
   inline ViewAttribute *get_attribute(ViewAttributeName name) const;
   inline Document *get_document() const {return document;}
   void emit_value_changed(View *origin, ViewAttribute *attr);
signals:
   void data_changed(AttrEvent *ev);
private slots:
   void doc_post_primitive_pre_view(Primitive *prim);
   void doc_post_primitive_post_view(Primitive *prim);
private:
   QPointer<Document> document;
   QHash<ViewAttributeName,ViewAttribute*> attributes;
};
//inline functions
inline ViewAttribute *ViewAttributeGroup::get_attribute(ViewAttributeName name) const {
   QHash<ViewAttributeName,ViewAttribute*>::const_iterator i = attributes.find(name);
   if (i == attributes.end())
      return NULL;
   return i.value();
}
#endif /* _VIEWATTRIBUTEGROUP_H */

